<template>
  <div class="wh100 flexbox flexbox_column">
    <div class="flexbox">
      <div class="flexCenter">
        <el-button type="success" size="default" style="width: 100px;height: 36px;" @click="returnHandler"
          >返回
        </el-button>
      </div>

      <div class="wh100 flexbox flex_center">
        <el-tabs v-model="activeName" @tab-click="handleClick">
          <el-tab-pane label="详情" name="1"> </el-tab-pane>
        </el-tabs>
      </div>
    </div>

    <div>
      <details-modules v-if="activeName == '1'" :info="infoModel"></details-modules>
    </div>
  </div>
</template>

<script>
// import details from './components/details.vue'
export default {
  props: {
    infoModel: {
      type: Object,
      default: () => ({}),
    },

    showModel: {
      type: Boolean,
      default: () => false,
    },
  },

  components: {
    detailsModules: () => import('./components/details.vue'),
  },

  watch: {
    showModel: {
      handler(val) {
        if (val) {
          console.log(val, this.infoModel)
          this.infoModel.inbound_packages_list.forEach(item => {
            item.ids_L = item.inbound_order_no
            item.children = item.inbound_packages_items_list || []

            item.warehouse_sku = item.children.length || 0 // 产品个数
            item.sku_total = 0 // sku总数量
            item.damaged_total = 0 // 破损数
            item.specimen_total = 0 // 标品数
            item.children.forEach(ele => {
              item.sku_total += ele.quantity || 0
              item.damaged_total += ele.damaged || 0
              item.specimen_total += ele.specimen || 0
              ele.ids_L = ele.package_no
              ele.isChildren = true
            })

            delete item.inbound_packages_items_list
          })

          this.$forceUpdate()
        }
      },
      deep: true,
      immediate: true,
    },
  },

  data() {
    return {
      activeName: '1',
    }
  },

  methods: {
    handleClick() {},

    resetForm() {
      this.$refs.ruleForm.resetFields()
      this.returnHandler()
    },

    returnHandler() {
      this.$emit('close', 'close')
    },
  },
}
</script>
